﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Uber.Storage;
using Uber.Messages;
using Uber.HabboHotel.GameClients;
using Uber.HabboHotel.Pathfinding;
using Uber.HabboHotel.Rooms;

namespace Uber.HabboHotel.Items.Interactors
{
    class InteractorDice : FurniInteractor
    {
        public override bool OnPlace(GameClient Session, RoomItem Item) { return true; }
        public override void OnRemove(GameClient Session, RoomItem Item)
        {
            if (Item.ExtraData == "-1")
            {
                Item.ExtraData = "0";
                Item.UpdateState();
            }
        }

        public override void OnTrigger(GameClient Session, RoomItem Item, int Request, bool UserHasRights)
        {
            RoomUser User = Item.GetRoom().GetRoomUserByHabbo(Session.GetHabbo().Id);

            if (User == null)
            {
                return;
            }

            if (Item.GetRoom().TilesTouching(Item.X, Item.Y, User.X, User.Y))
            {
                if (Item.ExtraData != "-1")
                {
                    if (Request == -1)
                    {
                        Item.ExtraData = "0";
                        Item.UpdateState();
                    }
                    else
                    {
                        Item.ExtraData = "-1";
                        Item.UpdateState(false, true);
                        Item.ReqUpdate(4);
                    }
                }
            }
            else
            {
                User.MoveTo(Item.SquareInFront);
            }
        }
    }
}
